<%@ taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@ taglib prefix="h" uri="http://java.sun.com/jsf/html" %>

<f:subview id="cart">
<h:form id="cartForm">
<h:outputText value="Your Shopping Cart is Empty" styleClass="title" rendered="#{cartBean.numberOfItems <= 0}"/>
<h:outputText value="Shopping Cart" styleClass="title" rendered="#{cartBean.numberOfItems > 0}"/>
<h:panelGrid columns="1" styleClass="box" rendered="#{cartBean.numberOfItems > 0}">
<h:dataTable id="cartTable" value="#{cartBean.cartItemList}" var="cartItem"  
	styleClass="standard"
	columnClasses="cartColumn1, cartColumn2, cartColumn3, cartColumn4">
  <h:column>
    <h:outputLink  value="item.jsf?itemId=#{cartItem.item.itemId}">
      <h:outputText value="#{cartItem.item.attribute1}" />
      <h:outputText value="#{cartItem.item.productName}"/>
    </h:outputLink>
  </h:column>
  <h:column>
    <h:commandLink action="#{cartBean.removeItemAction}">
      <h:outputText value="Remove"/>
      <f:param name="itemId" value="#{cartItem.item.itemId}"/>
    </h:commandLink>      
  </h:column>  
  <h:column> 
    <h:inputText value="#{cartItem.quantity}" size="5"/>
  </h:column>
  <h:column>
    <h:outputText value="@#{cartItem.item.unitCost}">
      <f:convertNumber type="currency"/>
    </h:outputText> 
  </h:column> 
</h:dataTable>
<h:panelGrid columns="3" styleClass="standard" 
	columnClasses="cartFooterColumn1, cartFooterColumn2, cartFooterColumn3" 
	rendered="#{cartBean.numberOfItems > 0}"> 
  <h:commandButton value="Update Cart" action="#{cartBean.updateAction}"/>
  <h:outputText value="Total: " styleClass="highLight"/>
  <h:outputText value="#{cartBean.cart.subTotal}">
	<f:convertNumber type="currency"/>
  </h:outputText>
</h:panelGrid> 
</h:panelGrid>
<h:panelGrid styleClass="standard" columnClasses="rightAlign" rendered="#{cartBean.numberOfItems > 0}">
  <h:outputLink  value="createOrder.jsf">
    <h:outputText value="Check Out" />
  </h:outputLink>  
</h:panelGrid>
</h:form>
</f:subview>